package com.demo.forum.model.exception;

import com.demo.forum.common.Result;

/**
 * 自定义异常
 */
public class ApplicationException extends RuntimeException{

    //在我们自己写的业务代码中,对于可预见的自定义异常,可以为异常设置一个定义好的错误
    protected Result errorResult;//Result 是一个统一结果返回类


    public ApplicationException(Result errResult) {
        super(errResult.getMessage());
        this.errorResult = errResult;

    }

    public ApplicationException(String message) {
        super(message);
    }

    public ApplicationException(String message, Throwable cause) {
        super(message, cause);
    }

    public ApplicationException(Throwable cause) {
        super(cause);
    }

    public ApplicationException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }

    public Result getErrorResult() {
        return errorResult;
    }
}
